import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 报警日志信息 */
export interface AlertLog {
          id: number; // ID
          ruleId?: number; // 规则ID
          deviceId?: number; // 设备ID
          state?: number; // 告警状态
          details: byte[]; // 详情
          timeLogged?: string | Dayjs; // 时间
  }

// 报警日志 API
export const AlertLogApi = {
  // 查询报警日志分页
  getAlertLogPage: async (params: any) => {
    return await request.get({ url: `/business/alert-log/page`, params })
  },

  // 查询报警日志详情
  getAlertLog: async (id: number) => {
    return await request.get({ url: `/business/alert-log/get?id=` + id })
  },

  // 新增报警日志
  createAlertLog: async (data: AlertLog) => {
    return await request.post({ url: `/business/alert-log/create`, data })
  },

  // 修改报警日志
  updateAlertLog: async (data: AlertLog) => {
    return await request.put({ url: `/business/alert-log/update`, data })
  },

  // 删除报警日志
  deleteAlertLog: async (id: number) => {
    return await request.delete({ url: `/business/alert-log/delete?id=` + id })
  },

  /** 批量删除报警日志 */
  deleteAlertLogList: async (ids: number[]) => {
    return await request.delete({ url: `/business/alert-log/delete-list?ids=${ids.join(',')}` })
  },

  // 导出报警日志 Excel
  exportAlertLog: async (params) => {
    return await request.download({ url: `/business/alert-log/export-excel`, params })
  },
}